

#pragma once

#include "zDbLinkedData.h"
#include "zDbTableIterator.h"
#include "zAcCell.h"

class UcDbLinkedTableData : public UcDbLinkedData
{
public:
    UCDB_DECLARE_MEMBERS(UcDbLinkedTableData);

    UCDB_PORT UcDbLinkedTableData(void);
    UCDB_PORT virtual ~UcDbLinkedTableData(void);

    UCDB_PORT virtual Ucad::ErrorStatus clear(void);
    UCDB_PORT virtual Ucad::ErrorStatus copyFrom(const UcDbLinkedTableData* pSrc, 
                                             UcDb::TableCopyOption nOption);
    UCDB_PORT virtual Ucad::ErrorStatus copyFrom(const UcDbLinkedTableData* pSrc, 
                                             UcDb::TableCopyOption nOption, 
                                             const UcCellRange& srcRange, 
                                             const UcCellRange& targetRange,
                                             UcCellRange* pNewTargetRange);
    UCDB_PORT UcDbTableIterator* getIterator(void) const;
    UCDB_PORT UcDbTableIterator* getIterator(const UcCellRange* pRange, 
                                             UcDb::TableIteratorOption nOption) const;

    UCDB_PORT virtual Ucad::ErrorStatus setSize(int nRows, int nCols);
    UCDB_PORT virtual int numColumns        (void) const;
    UCDB_PORT virtual const ZTCHAR* getColumnName(int nIndex) const;
    UCDB_PORT virtual Ucad::ErrorStatus setColumnName(int nIndex, 
                                             const ZTCHAR* pszName);
    UCDB_PORT virtual int appendColumn      (int nNumCols);
    UCDB_PORT virtual int insertColumn      (int nIndex, 
                                             int nNumCols);
    UCDB_PORT virtual Ucad::ErrorStatus deleteColumn(int nIndex, 
                                             int nNumColsToDelete);

    UCDB_PORT virtual int numRows           (void) const;
    UCDB_PORT virtual bool canInsert        (int nIndex, 
                                             bool bRow) const;
    UCDB_PORT virtual int appendRow         (int nNumRows);
    UCDB_PORT virtual int insertRow         (int nIndex, 
                                             int nNumRows);
    UCDB_PORT virtual bool canDelete        (int nIndex, 
                                             int nCount, 
                                             bool bRow) const;
    UCDB_PORT virtual Ucad::ErrorStatus deleteRow(int nIndex, 
                                             int nNumRowsToDelete);

    UCDB_PORT virtual bool isContentEditable(int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual UcDb::CellState cellState(int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual Ucad::ErrorStatus setCellState(int nRow, 
                                             int nCol, 
                                             UcDb::CellState nCellState);
    UCDB_PORT virtual UcString getToolTip   (int nRow,
                                             int nCol) const;
    UCDB_PORT virtual Ucad::ErrorStatus setToolTip(int nRow, 
                                             int nCol, 
                                             const ZTCHAR* pszToolTip);
    UCDB_PORT virtual int getCustomData     (int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual Ucad::ErrorStatus setCustomData(int nRow, 
                                             int nCol, 
                                             int nData);
    UCDB_PORT virtual Ucad::ErrorStatus getCustomData(int nRow, 
                                             int nCol, 
                                             const ZTCHAR* pszKey, 
                                             UcValue* pData) const;
    UCDB_PORT virtual Ucad::ErrorStatus setCustomData(int nRow, 
                                             int nCol, 
                                             const ZTCHAR* pszKey, 
                                             const UcValue* pData);
    UCDB_PORT virtual bool isLinked         (int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual UcDbObjectId getDataLink(int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual Ucad::ErrorStatus getDataLink(int nRow, 
                                             int nCol, 
                                             UcDbDataLink*& pDataLink, 
                                             UcDb::OpenMode mode) const;
    UCDB_PORT virtual int getDataLink       (const UcCellRange* pRange, 
                                             UcDbObjectIdArray& dataLinkIds) const;
    UCDB_PORT virtual Ucad::ErrorStatus setDataLink(int nRow, 
                                             int nCol, 
                                             const UcDbObjectId& idDataLink,
                                             bool bUpdate);
    UCDB_PORT virtual Ucad::ErrorStatus setDataLink(const UcCellRange& range, 
                                             const UcDbObjectId& idDataLink,
                                             bool bUpdate);
    UCDB_PORT virtual UcCellRange getDataLinkRange(int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual Ucad::ErrorStatus removeDataLink(int nRow, 
                                             int nCol);
    UCDB_PORT virtual Ucad::ErrorStatus removeDataLink(void);
    UCDB_PORT virtual Ucad::ErrorStatus updateDataLink(int nRow,
                                             int nCol, 
                                             UcDb::UpdateDirection nDir,
                                             UcDb::UpdateOption nOption);
    UCDB_PORT virtual Ucad::ErrorStatus updateDataLink(UcDb::UpdateDirection nDir, 
                                             UcDb::UpdateOption nOption);

    UCDB_PORT virtual int numContents       (int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual int createContent     (int nRow, 
                                             int nCol, 
                                             int nIndex);
    UCDB_PORT virtual Ucad::ErrorStatus moveContent(int nRow, 
                                             int nCol, 
                                             int nFromIndex, 
                                             int nToIndex);
    UCDB_PORT virtual Ucad::ErrorStatus deleteContent(int nRow, 
                                             int nCol, 
                                             int nContent);
    UCDB_PORT virtual Ucad::ErrorStatus deleteContent(int nRow, 
                                             int nCol);
    UCDB_PORT virtual Ucad::ErrorStatus deleteContent(const UcCellRange& range);

    UCDB_PORT virtual UcDb::CellContentType contentType(int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual UcDb::CellContentType contentType(int nRow, 
                                             int nCol, 
                                             int nContent) const;
    UCDB_PORT virtual Ucad::ErrorStatus getDataType(int nRow, 
                                             int nCol, 
                                             UcValue::DataType& nDataType,
                                             UcValue::UnitType& nUnitType) const;
    UCDB_PORT virtual Ucad::ErrorStatus getDataType(int nRow, 
                                             int nCol, 
                                             int nContent,
                                             UcValue::DataType& nDataType,
                                             UcValue::UnitType& nUnitType) const;
    UCDB_PORT virtual Ucad::ErrorStatus setDataType(int nRow, 
                                             int nCol, 
                                             UcValue::DataType nDataType,
                                             UcValue::UnitType nUnitType);
    UCDB_PORT virtual Ucad::ErrorStatus setDataType(int nRow, 
                                             int nCol, 
                                             int nContent,
                                             UcValue::DataType nDataType,
                                             UcValue::UnitType nUnitType);
    UCDB_PORT virtual UcString dataFormat   (int nRow,
                                             int nCol) const;
    UCDB_PORT virtual UcString dataFormat   (int nRow,
                                             int nCol,
                                             int nContent) const;
    UCDB_PORT virtual Ucad::ErrorStatus setDataFormat(int nRow, 
                                             int nCol, 
                                             const ZTCHAR* pszFormat);
    UCDB_PORT virtual Ucad::ErrorStatus setDataFormat(int nRow, 
                                             int nCol, 
                                             int nContent,
                                             const ZTCHAR* pszFormat);
    UCDB_PORT virtual Ucad::ErrorStatus getValue(int nRow, 
                                             int nCol, 
                                             UcValue& value) const;
    UCDB_PORT virtual Ucad::ErrorStatus getValue(int nRow, 
                                             int nCol, 
                                             int nContent, 
                                             UcValue::FormatOption nOption,
                                             UcValue& value) const;
    UCDB_PORT virtual Ucad::ErrorStatus setValue(int nRow, 
                                             int nCol, 
                                             const UcValue& value);
    UCDB_PORT virtual Ucad::ErrorStatus setValue(int nRow, 
                                             int nCol, 
                                             int nContent, 
                                             const UcValue& value);
    UCDB_PORT virtual Ucad::ErrorStatus setValue(int nRow, 
                                             int nCol, 
                                             int nContent, 
                                             const UcValue& value,
                                             UcValue::ParseOption nOption);
    UCDB_PORT virtual UcString getText      (int nRow,
                                             int nCol) const;
    UCDB_PORT virtual UcString getText      (int nRow,
                                             int nCol, 
                                             int nContent) const;
    UCDB_PORT virtual UcString getText      (int nRow,
                                             int nCol, 
                                             int nContent, 
                                             UcValue::FormatOption nOption) const;
    UCDB_PORT virtual Ucad::ErrorStatus setText(int nRow, 
                                             int nCol, 
                                             const ZTCHAR* pszText);
    UCDB_PORT virtual Ucad::ErrorStatus setText(int nRow, 
                                             int nCol, 
                                             int nContent, 
                                             const ZTCHAR* pszText);
    UCDB_PORT virtual bool hasFormula       (int nRow, 
                                             int nCol, 
                                             int nContent) const;
    UCDB_PORT virtual UcString getFormula   (int nRow,
                                             int nCol, 
                                             int nContent) const;
    UCDB_PORT virtual Ucad::ErrorStatus setFormula(int nRow, 
                                             int nCol, 
                                             int nContent, 
                                             const ZTCHAR* pszFormula);
    UCDB_PORT virtual UcDbObjectId getFieldId(int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual UcDbObjectId getFieldId(int nRow, 
                                             int nCol, 
                                             int nContent) const;
    UCDB_PORT virtual Ucad::ErrorStatus setFieldId(int nRow, 
                                             int nCol, 
                                             const UcDbObjectId& idField);
    UCDB_PORT virtual Ucad::ErrorStatus setFieldId(int nRow, 
                                             int nCol, 
                                             int nContent, 
                                             const UcDbObjectId& idField);
    UCDB_PORT virtual Ucad::ErrorStatus getField(int nRow, 
                                             int nCol, 
                                             int nContent,
                                             UcDbField*& pField,
                                             UcDb::OpenMode mode) const;
    UCDB_PORT virtual UcDbObjectId getBlockTableRecordId(int nRow, 
                                             int nCol) const;
    UCDB_PORT virtual UcDbObjectId getBlockTableRecordId(int nRow, 
                                             int nCol, 
                                             int nContent) const;
    UCDB_PORT virtual Ucad::ErrorStatus setBlockTableRecordId(int nRow, 
                                             int nCol, 
                                             const UcDbObjectId& idBTR);
    UCDB_PORT virtual Ucad::ErrorStatus setBlockTableRecordId(int nRow, 
                                             int nCol, 
                                             int nContent, 
                                             const UcDbObjectId& idBTR);
    UCDB_PORT virtual UcString getBlockAttributeValue(int nRow,
                                             int nCol, 
                                             const UcDbObjectId& idAttDef) const;
    UCDB_PORT virtual UcString getBlockAttributeValue(int nRow,
                                             int nCol, 
                                             int nContent, 
                                             const UcDbObjectId& idAttDef) const;
    UCDB_PORT virtual Ucad::ErrorStatus setBlockAttributeValue(int nRow, 
                                             int nCol, 
                                             const UcDbObjectId& idAttDef, 
                                             const ZTCHAR* pszAttValue);
    UCDB_PORT virtual Ucad::ErrorStatus setBlockAttributeValue(int nRow, 
                                             int nCol, 
                                             int nContent, 
                                             const UcDbObjectId& idAttDef, 
                                             const ZTCHAR* pszAttValue);

    UCDB_PORT virtual Ucad::ErrorStatus evaluateFormula(void);

    UCDB_PORT virtual Ucad::ErrorStatus dwgInFields(UcDbDwgFiler* pFiler);
    UCDB_PORT virtual Ucad::ErrorStatus dwgOutFields(UcDbDwgFiler* pFiler) const;
    UCDB_PORT virtual Ucad::ErrorStatus dxfInFields(UcDbDxfFiler* pFiler);
    UCDB_PORT virtual Ucad::ErrorStatus dxfOutFields(UcDbDxfFiler* pFiler) const;
};
